package main

import (
	"github.com/zh-five/xdaemon"
	"log"
	"os"
	"time"
)

func main() {
	logFile := "daemon.log"

	//启动一个子进程后主程序退出
	xdaemon.Background(logFile, true)

	//以下代码只有子程序会执行
	log.Println(os.Getpid(),os.Getppid(), "start...")
	for{
		time.Sleep(time.Second * 5)
		log.Println(os.Getpid(),os.Getppid(),time.Now().Format("2006-01-02 15:04:05"))
	}
	log.Println(os.Getpid(), "end")

}